home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Activity command *)
- (* *)
- (* Copyright 1988, 1989, 1991 by H. Roy Engehausen. All rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- {$O+}
-
- UNIT BBACTCMD;
-
- INTERFACE
-
- PROCEDURE activity_cmd(cmd_string : STRING);
-
- IMPLEMENTATION
-
- USES
- bbdummy,
- bbmdata,
- bbmess,
- bbmisc,
- bbsdata,
- bbstr;
-
- PROCEDURE list_ports; FORWARD;
- PROCEDURE list_current_users; FORWARD;
-
- (*===========================================================================*)
- (* Activity command *)
- (* Entered when 'J' received by command processor *)
- (*===========================================================================*)
-
- PROCEDURE activity_cmd(cmd_string : STRING);
-
- VAR
- c : CHAR;
- found : BOOLEAN;
- i : WORD;
- p_ptr : port_block_ptr;
- s_ptr : port_block_ptr;
- t_str : STRING;
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* Must be simple command *)
- (*-----------------------------------------------------------------------*)
-
- IF WORDS(cmd_string) > 1 THEN
- BEGIN;
- send_message(message_err_wrd);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Handle one letter command *)
- (*-----------------------------------------------------------------------*)
-
- IF LENGTH(cmd_string) = 1 THEN
- BEGIN;
- list_ports;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Get second letter of command *)
- (*-----------------------------------------------------------------------*)
-
- c := UPCASE(cmd_string[2]);
-
- (*-----------------------------------------------------------------------*)
- (* Handle list current users *)
- (*-----------------------------------------------------------------------*)
-
- IF c = 'N' THEN
- BEGIN;
- list_current_users;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Find port *)
- (*-----------------------------------------------------------------------*)
-
- IF c = 'L' THEN
- p_ptr := @dummy_port
- ELSE
- BEGIN;
-
- s_ptr := active_port;
-
- IF find_port(c) THEN
- p_ptr := active_port
- ELSE
- p_ptr := NIL;
-
- active_port := s_ptr;
- active_tcb^.tcb_port := s_ptr;
-
- IF p_ptr = NIL THEN
- BEGIN;
- send_message(message_err_2nd);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- END;
-
- (*-----------------------------------------------------------------------*)
- (* List the data *)
- (*-----------------------------------------------------------------------*)
-
- found := FALSE;
-
- FOR i := 1 TO opt_block.n_mon DO
- WITH p_ptr^.call_list^[i] DO
- IF port_call_sign <> '' THEN
- BEGIN;
- c := port_call_port;
- IF c < 'A' THEN
- c := CHR(ORD(c) + ORD('A'));
- send_tnc_data_str(LEFT(port_call_sign, SIZEOF(port_call_sign))
- + c + ' ' + port_call_date + cr);
- found := TRUE;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Nothing found? *)
- (*-----------------------------------------------------------------------*)
-
- IF NOT found THEN
- send_message(message_jn_no_users);
-
- END;
-
- (*===========================================================================*)
- (* Provides a list of ports *)
- (*===========================================================================*)
-
- PROCEDURE list_ports;
-
- VAR
- p_ptr : port_block_ptr;
-
- BEGIN;
-
- p_ptr := ring_port;
-
- REPEAT
- WITH p_ptr^ DO
- BEGIN;
- send_tnc_data_str('J' + port_char + ' - ' + port_name + cr);
- p_ptr := next_port;
- END;
- UNTIL p_ptr = ring_port;
-
- send_message(message_j_list_end);
-
- END;
-
- (*===========================================================================*)
- (* Provides a list of current users *)
- (* Code contributed by NQ1C *)
- (*===========================================================================*)
-
- PROCEDURE list_current_users;
-
- VAR
- t_str : STRING[150];
- w_tcb : tcb_ptr;
- found : BOOLEAN;
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* Initialize threads *)
- (*-----------------------------------------------------------------------*)
-
- w_tcb := ring_tcb;
-
- found := FALSE;
-
- (*-----------------------------------------------------------------------*)
- (* Loop for all threads *)
- (*-----------------------------------------------------------------------*)
-
- REPEAT
-
- WITH w_tcb^ DO
- BEGIN;
-
- (*-----------------------------------------------------------------*)
- (* Make sure it has a name *)
- (*-----------------------------------------------------------------*)
-
- IF tcb_name <> '' THEN
- BEGIN;
-
- (*-------------------------------------------------------------*)
- (* yes.. We found something to tell about *)
- (*-------------------------------------------------------------*)
-
- found := TRUE;
-
- (*-------------------------------------------------------------*)
- (* Put the job name and user info in the line *)
- (*-------------------------------------------------------------*)
-
- t_str := port_chan_s + ' ' + tcb_name + ' ';
-
- (*-------------------------------------------------------------*)
- (* If there is name, display it *)
- (*-------------------------------------------------------------*)
-
- IF (uid_data.user_name <> '?') AND (uid_data.user_name <> '') THEN
- t_str := t_str + '[' + uid_data.user_name + '] ';
-
- (*-------------------------------------------------------------*)
- (* Get description of task *)
- (*-------------------------------------------------------------*)
-
- CASE tcb_type OF
-
- th_fwd_slave :
- BEGIN;
- t_str := t_str + get_message(message_jn_out_fwd);
- IF NOT tcb_abbs THEN
- t_str := t_str + get_message(message_jn_cip);
- END;
-
- th_user :
- BEGIN;
-
- (*-----------------------------------------------------*)
- (* BBS connected? *)
- (*-----------------------------------------------------*)
-
- IF tcb_abbs THEN
- t_str := t_str + get_message(message_jn_in_fwd);
-
- (*-----------------------------------------------------*)
- (* Operator talking to him? *)
- (*-----------------------------------------------------*)
-
- IF tcb_opr_talk THEN
- t_str := t_str + get_message(message_jn_t_sysop);
-
- END;
-
- th_opr_terminal, th_answer:
-
- t_str := t_str + get_message(message_jn_st);
-
- ELSE
- ;
-
- END; (*----- End case statement -------------------------------*)
-
- (*-------------------------------------------------------------*)
- (* Reverse forward? *)
- (*-------------------------------------------------------------*)
-
- IF tcb_rev_fwd THEN
- t_str := t_str + get_message(message_jn_r_fwd);
-
- (*-------------------------------------------------------------*)
- (* Send the data *)
- (*-------------------------------------------------------------*)
-
- send_tnc_data_str(t_str + cr);
-
- END;
-
- (*-----------------------------------------------------------------*)
- (* Chain to next thread *)
- (*-----------------------------------------------------------------*)
-
- w_tcb := w_tcb^.next_tcb;
-
- END;
-
- UNTIL w_tcb = ring_tcb; (*----- End loop thru all threads ---------------*)
-
- (*-----------------------------------------------------------------------*)
- (* Nothing found *)
- (*-----------------------------------------------------------------------*)
-
- IF NOT found THEN
- send_message(message_jn_no_users);
-
- END;
-
- END.